package com.hzdp.web.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.hzdp.entity.Product;
import com.hzdp.service.ProductService;
import com.hzdp.web.action.review.vo.ProductVo;

public class ProductListAction extends BaseAction {
	private String name;
	private int offset;
	private int pageSize;
	private List<ProductVo> productList;
	
	@Autowired
	private ProductService productService;

	@Override
	public String execute() {
		List<Product> list;
		list = productService.findAll(name.trim(), offset, pageSize);
		if (list != null && list.size() > 0) {
			for (Product product : list) {
				ProductVo vo = new ProductVo();
				vo.setName(product.getName());
				vo.setPicture(product.getPicture());
				vo.setStar(product.getStar());
//				vo.setReviewNum(product.get);
				productList.add(vo);
			}
		}
		return "success";
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setOffset(int offset) {
		this.offset = offset;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public List<ProductVo> getProductList() {
		return productList;
	}
}
